package com.yx.study.leet.primary.sort;

/**
 * @Classname Merge
 * @Date 2023/01/15 20:41
 * @Author by yx
 * @Description : 合并两个有序数组 - 合并排序(一般从小到大, 此次从大到小)
 * https://leetcode.cn/leetbook/read/top-interview-questions-easy/xnumcr/
 */
public class Merge {
    public void merge(int[] nums1, int m, int[] nums2, int n) {
        int i = m - 1;
        int j = n - 1;
        int end = m + n - 1;
        while (j >= 0) {
            nums1[end--] = (i >= 0 && nums1[i] > nums2[j]) ? nums1[i--] : nums2[j--];
        }
    }
}
